package com.demo.gateway.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import com.demo.gateway.pojo.RecordDO;

/**
 * @author: demo
 * @date: 2020年7月2日
 * @Document : 记录操作类
 */
@Mapper
public interface RequestRecordMapper {
	
	/**
	 * 添加日志记录
	 * @param record
	 * @return
	 */
	@Insert({"insert into gateway_record (id,request_address,client_address,gateway_address,url,method,request_header,request_param,response_body,start_time,end_time,spend_time) "
			+ " values (#{id},#{requestAddress},#{clientAddress},#{gatewayAddress},#{url},#{method},#{requestHeader},#{requestParam},#{responseBody},#{startTime},#{endTime},#{spendTime})"})
	public  int  addRecord(RecordDO record);
	
	/**
	 * 更新日志响应信息
	 * @param record
	 * @return
	 */
	@Update({"update gateway_record set response_body=#{responseBody},end_time=#{endTime}"
			+ ",spend_time=#{spendTime} where  id=#{id}"})
	public  int updateRecordResponse(RecordDO record);
	
	/**
	 * 更新日志请求信息
	 * @param record
	 * @return
	 */
	@Update({"update gateway_record set request_param=#{requestParam} where  id=#{id}"})
	public  int updateRecordRequest(RecordDO record);
}
